﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JM.JCY.BusinessEntity;

namespace JM.JCY.DataAccess
{
    public class AnnounceDA : JCYDataAccessBasecs
    {
        public void UpdateAnnounce(AnnounceDataSet ds)
        {
            base.Helper.Update(ds);
        }

        public void UpdateAnnouceSingle(AnnounceDataSet.T_AnnounceDataTable dt)
        {
            base.Helper.Update(dt);
        }

        public void UpdateAnnounceReceiverSingle(AnnounceDataSet.T_Announce_ReceiverDataTable dt)
        {
            base.Helper.Update(dt);
        }

        public AnnounceDataSet.T_Announce_ReceiverDataTable GetAnnounceReceiverById(int announceId)
        {
            var dt = new AnnounceDataSet.T_Announce_ReceiverDataTable();
            base.Helper.Fill(dt, "P_Announce_Receiver_S_ByAnnounceId", announceId);
            return dt;
        }

        public AnnounceDataSet.T_Announce_SearchDataTable SearchAnnounce(string subject, string status, string readStatus, DateTime? startDate, DateTime? endDate)
        {
            var dt = new AnnounceDataSet.T_Announce_SearchDataTable();
            base.Helper.Fill(dt, "P_Announce_Search", subject, status, readStatus, startDate, endDate);
            return dt;
        }

        public AnnounceDataSet.T_AnnounceDataTable GetAnnounce(int announceId, string subject, string status)
        {
            var dt = new AnnounceDataSet.T_AnnounceDataTable();
            base.Helper.Fill(dt, "P_Announce_S_General", announceId, subject, status);
            return dt;
        }

        public AnnounceDataSet.T_Announce_Search_By_UserDataTable SearchAnnounceByUser(string subject, DateTime? startDate, DateTime? endDate, int currentUserId)
        {
            var dt = new AnnounceDataSet.T_Announce_Search_By_UserDataTable();
            base.Helper.Fill(dt, "P_Announce_Search_ByUser", subject, startDate, endDate, currentUserId);
            return dt;
        }

        public AnnounceDataSet.T_AnnounceDataTable SearchAnnouncForHome(int count, int receiverId)
        {
            var dt = new AnnounceDataSet.T_AnnounceDataTable();
            base.Helper.Fill(dt, "P_Announce_S_forHome", count, receiverId);
            return dt;
        }


        public void UpdateAnnounceStatus(int annId, string userName)
        {
            Helper.ExecuteNonQuery("P_UpdateAnnounceStatusByAnnIdUserName_U", annId, userName);
        }

    }
}
